home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 24 / AACD 24.iso / AACD / Programming / gcc-2.95.3-3 / info / gcc.info-24 < prev    next >
Encoding:
GNU Info File  |  2001-07-15  |  46.2 KB  |  983 lines

  1. This is Info file gcc.info, produced by Makeinfo version 1.68 from the
  2. input file ./gcc.texi.
  3.  
  4. INFO-DIR-SECTION Programming
  5. START-INFO-DIR-ENTRY
  6. * gcc: (gcc).                  The GNU Compiler Collection.
  7. END-INFO-DIR-ENTRY
  8.    This file documents the use and the internals of the GNU compiler.
  9.  
  10.    Published by the Free Software Foundation 59 Temple Place - Suite 330
  11. Boston, MA 02111-1307 USA
  12.  
  13.    Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
  14. 1999, 2000 Free Software Foundation, Inc.
  15.  
  16.    Permission is granted to make and distribute verbatim copies of this
  17. manual provided the copyright notice and this permission notice are
  18. preserved on all copies.
  19.  
  20.    Permission is granted to copy and distribute modified versions of
  21. this manual under the conditions for verbatim copying, provided also
  22. that the sections entitled "GNU General Public License" and "Funding
  23. for Free Software" are included exactly as in the original, and
  24. provided that the entire resulting derived work is distributed under
  25. the terms of a permission notice identical to this one.
  26.  
  27.    Permission is granted to copy and distribute translations of this
  28. manual into another language, under the above conditions for modified
  29. versions, except that the sections entitled "GNU General Public
  30. License" and "Funding for Free Software", and this permission notice,
  31. may be included in translations approved by the Free Software Foundation
  32. instead of in the original English.
  33.  
  34. 
  35. File: gcc.info,  Node: Register Arguments,  Next: Scalar Return,  Prev: Stack Arguments,  Up: Stack and Calling
  36.  
  37. Passing Arguments in Registers
  38. ------------------------------
  39.  
  40.    This section describes the macros which let you control how various
  41. types of arguments are passed in registers or how they are arranged in
  42. the stack.
  43.  
  44. `FUNCTION_ARG (CUM, MODE, TYPE, NAMED)'
  45.      A C expression that controls whether a function argument is passed
  46.      in a register, and which register.
  47.  
  48.      The arguments are CUM, which summarizes all the previous
  49.      arguments; MODE, the machine mode of the argument; TYPE, the data
  50.      type of the argument as a tree node or 0 if that is not known
  51.      (which happens for C support library functions); and NAMED, which
  52.      is 1 for an ordinary argument and 0 for nameless arguments that
  53.      correspond to `...' in the called function's prototype.
  54.  
  55.      The value of the expression is usually either a `reg' RTX for the
  56.      hard register in which to pass the argument, or zero to pass the
  57.      argument on the stack.
  58.  
  59.      For machines like the Vax and 68000, where normally all arguments
  60.      are pushed, zero suffices as a definition.
  61.  
  62.      The value of the expression can also be a `parallel' RTX.  This is
  63.      used when an argument is passed in multiple locations.  The mode
  64.      of the of the `parallel' should be the mode of the entire
  65.      argument.  The `parallel' holds any number of `expr_list' pairs;
  66.      each one describes where part of the argument is passed.  In each
  67.      `expr_list' the first operand must be a `reg' RTX for the hard
  68.      register in which to pass this part of the argument, and the mode
  69.      of the register RTX indicates how large this part of the argument
  70.      is.  The second operand of the `expr_list' is a `const_int' which
  71.      gives the offset in bytes into the entire argument of where this
  72.      part starts.  As a special exception the first `expr_list' in the
  73.      `parallel' RTX may have a first operand of zero.  This indicates
  74.      that the bytes starting from the second operand of that
  75.      `expr_list' are stored on the stack and not held in a register.
  76.  
  77.      The usual way to make the ANSI library `stdarg.h' work on a machine
  78.      where some arguments are usually passed in registers, is to cause
  79.      nameless arguments to be passed on the stack instead.  This is done
  80.      by making `FUNCTION_ARG' return 0 whenever NAMED is 0.
  81.  
  82.      You may use the macro `MUST_PASS_IN_STACK (MODE, TYPE)' in the
  83.      definition of this macro to determine if this argument is of a
  84.      type that must be passed in the stack.  If `REG_PARM_STACK_SPACE'
  85.      is not defined and `FUNCTION_ARG' returns non-zero for such an
  86.      argument, the compiler will abort.  If `REG_PARM_STACK_SPACE' is
  87.      defined, the argument will be computed in the stack and then
  88.      loaded into a register.
  89.  
  90. `MUST_PASS_IN_STACK (MODE, TYPE)'
  91.      Define as a C expression that evaluates to nonzero if we do not
  92.      know how to pass TYPE solely in registers.  The file `expr.h'
  93.      defines a definition that is usually appropriate, refer to
  94.      `expr.h' for additional documentation.
  95.  
  96. `FUNCTION_INCOMING_ARG (CUM, MODE, TYPE, NAMED)'
  97.      Define this macro if the target machine has "register windows", so
  98.      that the register in which a function sees an arguments is not
  99.      necessarily the same as the one in which the caller passed the
  100.      argument.
  101.  
  102.      For such machines, `FUNCTION_ARG' computes the register in which
  103.      the caller passes the value, and `FUNCTION_INCOMING_ARG' should be
  104.      defined in a similar fashion to tell the function being called
  105.      where the arguments will arrive.
  106.  
  107.      If `FUNCTION_INCOMING_ARG' is not defined, `FUNCTION_ARG' serves
  108.      both purposes.
  109.  
  110. `FUNCTION_ARG_PARTIAL_NREGS (CUM, MODE, TYPE, NAMED)'
  111.      A C expression for the number of words, at the beginning of an
  112.      argument, must be put in registers.  The value must be zero for
  113.      arguments that are passed entirely in registers or that are
  114.      entirely pushed on the stack.
  115.  
  116.      On some machines, certain arguments must be passed partially in
  117.      registers and partially in memory.  On these machines, typically
  118.      the first N words of arguments are passed in registers, and the
  119.      rest on the stack.  If a multi-word argument (a `double' or a
  120.      structure) crosses that boundary, its first few words must be
  121.      passed in registers and the rest must be pushed.  This macro tells
  122.      the compiler when this occurs, and how many of the words should go
  123.      in registers.
  124.  
  125.      `FUNCTION_ARG' for these arguments should return the first
  126.      register to be used by the caller for this argument; likewise
  127.      `FUNCTION_INCOMING_ARG', for the called function.
  128.  
  129. `FUNCTION_ARG_PASS_BY_REFERENCE (CUM, MODE, TYPE, NAMED)'
  130.      A C expression that indicates when an argument must be passed by
  131.      reference.  If nonzero for an argument, a copy of that argument is
  132.      made in memory and a pointer to the argument is passed instead of
  133.      the argument itself.  The pointer is passed in whatever way is
  134.      appropriate for passing a pointer to that type.
  135.  
  136.      On machines where `REG_PARM_STACK_SPACE' is not defined, a suitable
  137.      definition of this macro might be
  138.           #define FUNCTION_ARG_PASS_BY_REFERENCE\
  139.           (CUM, MODE, TYPE, NAMED)  \
  140.             MUST_PASS_IN_STACK (MODE, TYPE)
  141.  
  142. `FUNCTION_ARG_CALLEE_COPIES (CUM, MODE, TYPE, NAMED)'
  143.      If defined, a C expression that indicates when it is the called
  144.      function's responsibility to make a copy of arguments passed by
  145.      invisible reference.  Normally, the caller makes a copy and passes
  146.      the address of the copy to the routine being called.  When
  147.      FUNCTION_ARG_CALLEE_COPIES is defined and is nonzero, the caller
  148.      does not make a copy.  Instead, it passes a pointer to the "live"
  149.      value.  The called function must not modify this value.  If it can
  150.      be determined that the value won't be modified, it need not make a
  151.      copy; otherwise a copy must be made.
  152.  
  153. `CUMULATIVE_ARGS'
  154.      A C type for declaring a variable that is used as the first
  155.      argument of `FUNCTION_ARG' and other related values.  For some
  156.      target machines, the type `int' suffices and can hold the number
  157.      of bytes of argument so far.
  158.  
  159.      There is no need to record in `CUMULATIVE_ARGS' anything about the
  160.      arguments that have been passed on the stack.  The compiler has
  161.      other variables to keep track of that.  For target machines on
  162.      which all arguments are passed on the stack, there is no need to
  163.      store anything in `CUMULATIVE_ARGS'; however, the data structure
  164.      must exist and should not be empty, so use `int'.
  165.  
  166. `INIT_CUMULATIVE_ARGS (CUM, FNTYPE, LIBNAME, INDIRECT)'
  167.      A C statement (sans semicolon) for initializing the variable CUM
  168.      for the state at the beginning of the argument list.  The variable
  169.      has type `CUMULATIVE_ARGS'.  The value of FNTYPE is the tree node
  170.      for the data type of the function which will receive the args, or 0
  171.      if the args are to a compiler support library function.  The value
  172.      of INDIRECT is nonzero when processing an indirect call, for
  173.      example a call through a function pointer.  The value of INDIRECT
  174.      is zero for a call to an explicitly named function, a library
  175.      function call, or when `INIT_CUMULATIVE_ARGS' is used to find
  176.      arguments for the function being compiled.
  177.  
  178.      When processing a call to a compiler support library function,
  179.      LIBNAME identifies which one.  It is a `symbol_ref' rtx which
  180.      contains the name of the function, as a string.  LIBNAME is 0 when
  181.      an ordinary C function call is being processed.  Thus, each time
  182.      this macro is called, either LIBNAME or FNTYPE is nonzero, but
  183.      never both of them at once.
  184.  
  185. `INIT_CUMULATIVE_INCOMING_ARGS (CUM, FNTYPE, LIBNAME)'
  186.      Like `INIT_CUMULATIVE_ARGS' but overrides it for the purposes of
  187.      finding the arguments for the function being compiled.  If this
  188.      macro is undefined, `INIT_CUMULATIVE_ARGS' is used instead.
  189.  
  190.      The value passed for LIBNAME is always 0, since library routines
  191.      with special calling conventions are never compiled with GNU CC.
  192.      The argument LIBNAME exists for symmetry with
  193.      `INIT_CUMULATIVE_ARGS'.
  194.  
  195. `FUNCTION_ARG_ADVANCE (CUM, MODE, TYPE, NAMED)'
  196.      A C statement (sans semicolon) to update the summarizer variable
  197.      CUM to advance past an argument in the argument list.  The values
  198.      MODE, TYPE and NAMED describe that argument.  Once this is done,
  199.      the variable CUM is suitable for analyzing the *following*
  200.      argument with `FUNCTION_ARG', etc.
  201.  
  202.      This macro need not do anything if the argument in question was
  203.      passed on the stack.  The compiler knows how to track the amount
  204.      of stack space used for arguments without any special help.
  205.  
  206. `FUNCTION_ARG_PADDING (MODE, TYPE)'
  207.      If defined, a C expression which determines whether, and in which
  208.      direction, to pad out an argument with extra space.  The value
  209.      should be of type `enum direction': either `upward' to pad above
  210.      the argument, `downward' to pad below, or `none' to inhibit
  211.      padding.
  212.  
  213.      The *amount* of padding is always just enough to reach the next
  214.      multiple of `FUNCTION_ARG_BOUNDARY'; this macro does not control
  215.      it.
  216.  
  217.      This macro has a default definition which is right for most
  218.      systems.  For little-endian machines, the default is to pad
  219.      upward.  For big-endian machines, the default is to pad downward
  220.      for an argument of constant size shorter than an `int', and upward
  221.      otherwise.
  222.  
  223. `FUNCTION_ARG_BOUNDARY (MODE, TYPE)'
  224.      If defined, a C expression that gives the alignment boundary, in
  225.      bits, of an argument with the specified mode and type.  If it is
  226.      not defined, `PARM_BOUNDARY' is used for all arguments.
  227.  
  228. `FUNCTION_ARG_REGNO_P (REGNO)'
  229.      A C expression that is nonzero if REGNO is the number of a hard
  230.      register in which function arguments are sometimes passed.  This
  231.      does *not* include implicit arguments such as the static chain and
  232.      the structure-value address.  On many machines, no registers can be
  233.      used for this purpose since all function arguments are pushed on
  234.      the stack.
  235.  
  236. `LOAD_ARGS_REVERSED'
  237.      If defined, the order in which arguments are loaded into their
  238.      respective argument registers is reversed so that the last
  239.      argument is loaded first.  This macro only effects arguments
  240.      passed in registers.
  241.  
  242. 
  243. File: gcc.info,  Node: Scalar Return,  Next: Aggregate Return,  Prev: Register Arguments,  Up: Stack and Calling
  244.  
  245. How Scalar Function Values Are Returned
  246. ---------------------------------------
  247.  
  248.    This section discusses the macros that control returning scalars as
  249. values--values that can fit in registers.
  250.  
  251. `TRADITIONAL_RETURN_FLOAT'
  252.      Define this macro if `-traditional' should not cause functions
  253.      declared to return `float' to convert the value to `double'.
  254.  
  255. `FUNCTION_VALUE (VALTYPE, FUNC)'
  256.      A C expression to create an RTX representing the place where a
  257.      function returns a value of data type VALTYPE.  VALTYPE is a tree
  258.      node representing a data type.  Write `TYPE_MODE (VALTYPE)' to get
  259.      the machine mode used to represent that type.  On many machines,
  260.      only the mode is relevant.  (Actually, on most machines, scalar
  261.      values are returned in the same place regardless of mode).
  262.  
  263.      The value of the expression is usually a `reg' RTX for the hard
  264.      register where the return value is stored.  The value can also be a
  265.      `parallel' RTX, if the return value is in multiple places.  See
  266.      `FUNCTION_ARG' for an explanation of the `parallel' form.
  267.  
  268.      If `PROMOTE_FUNCTION_RETURN' is defined, you must apply the same
  269.      promotion rules specified in `PROMOTE_MODE' if VALTYPE is a scalar
  270.      type.
  271.  
  272.      If the precise function being called is known, FUNC is a tree node
  273.      (`FUNCTION_DECL') for it; otherwise, FUNC is a null pointer.  This
  274.      makes it possible to use a different value-returning convention
  275.      for specific functions when all their calls are known.
  276.  
  277.      `FUNCTION_VALUE' is not used for return vales with aggregate data
  278.      types, because these are returned in another way.  See
  279.      `STRUCT_VALUE_REGNUM' and related macros, below.
  280.  
  281. `FUNCTION_OUTGOING_VALUE (VALTYPE, FUNC)'
  282.      Define this macro if the target machine has "register windows" so
  283.      that the register in which a function returns its value is not the
  284.      same as the one in which the caller sees the value.
  285.  
  286.      For such machines, `FUNCTION_VALUE' computes the register in which
  287.      the caller will see the value.  `FUNCTION_OUTGOING_VALUE' should be
  288.      defined in a similar fashion to tell the function where to put the
  289.      value.
  290.  
  291.      If `FUNCTION_OUTGOING_VALUE' is not defined, `FUNCTION_VALUE'
  292.      serves both purposes.
  293.  
  294.      `FUNCTION_OUTGOING_VALUE' is not used for return vales with
  295.      aggregate data types, because these are returned in another way.
  296.      See `STRUCT_VALUE_REGNUM' and related macros, below.
  297.  
  298. `LIBCALL_VALUE (MODE)'
  299.      A C expression to create an RTX representing the place where a
  300.      library function returns a value of mode MODE.  If the precise
  301.      function being called is known, FUNC is a tree node
  302.      (`FUNCTION_DECL') for it; otherwise, FUNC is a null pointer.  This
  303.      makes it possible to use a different value-returning convention
  304.      for specific functions when all their calls are known.
  305.  
  306.      Note that "library function" in this context means a compiler
  307.      support routine, used to perform arithmetic, whose name is known
  308.      specially by the compiler and was not mentioned in the C code being
  309.      compiled.
  310.  
  311.      The definition of `LIBRARY_VALUE' need not be concerned aggregate
  312.      data types, because none of the library functions returns such
  313.      types.
  314.  
  315. `FUNCTION_VALUE_REGNO_P (REGNO)'
  316.      A C expression that is nonzero if REGNO is the number of a hard
  317.      register in which the values of called function may come back.
  318.  
  319.      A register whose use for returning values is limited to serving as
  320.      the second of a pair (for a value of type `double', say) need not
  321.      be recognized by this macro.  So for most machines, this definition
  322.      suffices:
  323.  
  324.           #define FUNCTION_VALUE_REGNO_P(N) ((N) == 0)
  325.  
  326.      If the machine has register windows, so that the caller and the
  327.      called function use different registers for the return value, this
  328.      macro should recognize only the caller's register numbers.
  329.  
  330. `APPLY_RESULT_SIZE'
  331.      Define this macro if `untyped_call' and `untyped_return' need more
  332.      space than is implied by `FUNCTION_VALUE_REGNO_P' for saving and
  333.      restoring an arbitrary return value.
  334.  
  335. 
  336. File: gcc.info,  Node: Aggregate Return,  Next: Caller Saves,  Prev: Scalar Return,  Up: Stack and Calling
  337.  
  338. How Large Values Are Returned
  339. -----------------------------
  340.  
  341.    When a function value's mode is `BLKmode' (and in some other cases),
  342. the value is not returned according to `FUNCTION_VALUE' (*note Scalar
  343. Return::.).  Instead, the caller passes the address of a block of
  344. memory in which the value should be stored.  This address is called the
  345. "structure value address".
  346.  
  347.    This section describes how to control returning structure values in
  348. memory.
  349.  
  350. `RETURN_IN_MEMORY (TYPE)'
  351.      A C expression which can inhibit the returning of certain function
  352.      values in registers, based on the type of value.  A nonzero value
  353.      says to return the function value in memory, just as large
  354.      structures are always returned.  Here TYPE will be a C expression
  355.      of type `tree', representing the data type of the value.
  356.  
  357.      Note that values of mode `BLKmode' must be explicitly handled by
  358.      this macro.  Also, the option `-fpcc-struct-return' takes effect
  359.      regardless of this macro.  On most systems, it is possible to
  360.      leave the macro undefined; this causes a default definition to be
  361.      used, whose value is the constant 1 for `BLKmode' values, and 0
  362.      otherwise.
  363.  
  364.      Do not use this macro to indicate that structures and unions
  365.      should always be returned in memory.  You should instead use
  366.      `DEFAULT_PCC_STRUCT_RETURN' to indicate this.
  367.  
  368. `DEFAULT_PCC_STRUCT_RETURN'
  369.      Define this macro to be 1 if all structure and union return values
  370.      must be in memory.  Since this results in slower code, this should
  371.      be defined only if needed for compatibility with other compilers
  372.      or with an ABI.  If you define this macro to be 0, then the
  373.      conventions used for structure and union return values are decided
  374.      by the `RETURN_IN_MEMORY' macro.
  375.  
  376.      If not defined, this defaults to the value 1.
  377.  
  378. `STRUCT_VALUE_REGNUM'
  379.      If the structure value address is passed in a register, then
  380.      `STRUCT_VALUE_REGNUM' should be the number of that register.
  381.  
  382. `STRUCT_VALUE'
  383.      If the structure value address is not passed in a register, define
  384.      `STRUCT_VALUE' as an expression returning an RTX for the place
  385.      where the address is passed.  If it returns 0, the address is
  386.      passed as an "invisible" first argument.
  387.  
  388. `STRUCT_VALUE_INCOMING_REGNUM'
  389.      On some architectures the place where the structure value address
  390.      is found by the called function is not the same place that the
  391.      caller put it.  This can be due to register windows, or it could
  392.      be because the function prologue moves it to a different place.
  393.  
  394.      If the incoming location of the structure value address is in a
  395.      register, define this macro as the register number.
  396.  
  397. `STRUCT_VALUE_INCOMING'
  398.      If the incoming location is not a register, then you should define
  399.      `STRUCT_VALUE_INCOMING' as an expression for an RTX for where the
  400.      called function should find the value.  If it should find the
  401.      value on the stack, define this to create a `mem' which refers to
  402.      the frame pointer.  A definition of 0 means that the address is
  403.      passed as an "invisible" first argument.
  404.  
  405. `PCC_STATIC_STRUCT_RETURN'
  406.      Define this macro if the usual system convention on the target
  407.      machine for returning structures and unions is for the called
  408.      function to return the address of a static variable containing the
  409.      value.
  410.  
  411.      Do not define this if the usual system convention is for the
  412.      caller to pass an address to the subroutine.
  413.  
  414.      This macro has effect in `-fpcc-struct-return' mode, but it does
  415.      nothing when you use `-freg-struct-return' mode.
  416.  
  417. 
  418. File: gcc.info,  Node: Caller Saves,  Next: Function Entry,  Prev: Aggregate Return,  Up: Stack and Calling
  419.  
  420. Caller-Saves Register Allocation
  421. --------------------------------
  422.  
  423.    If you enable it, GNU CC can save registers around function calls.
  424. This makes it possible to use call-clobbered registers to hold
  425. variables that must live across calls.
  426.  
  427. `DEFAULT_CALLER_SAVES'
  428.      Define this macro if function calls on the target machine do not
  429.      preserve any registers; in other words, if `CALL_USED_REGISTERS'
  430.      has 1 for all registers.  When defined, this macro enables
  431.      `-fcaller-saves' by default for all optimization levels.  It has
  432.      no effect for optimization levels 2 and higher, where
  433.      `-fcaller-saves' is the default.
  434.  
  435. `CALLER_SAVE_PROFITABLE (REFS, CALLS)'
  436.      A C expression to determine whether it is worthwhile to consider
  437.      placing a pseudo-register in a call-clobbered hard register and
  438.      saving and restoring it around each function call.  The expression
  439.      should be 1 when this is worth doing, and 0 otherwise.
  440.  
  441.      If you don't define this macro, a default is used which is good on
  442.      most machines: `4 * CALLS < REFS'.
  443.  
  444. `HARD_REGNO_CALLER_SAVE_MODE (REGNO, NREGS)'
  445.      A C expression specifying which mode is required for saving NREGS
  446.      of a pseudo-register in call-clobbered hard register REGNO.  If
  447.      REGNO is unsuitable for caller save, `VOIDmode' should be
  448.      returned.  For most machines this macro need not be defined since
  449.      GCC will select the smallest suitable mode.
  450.  
  451. 
  452. File: gcc.info,  Node: Function Entry,  Next: Profiling,  Prev: Caller Saves,  Up: Stack and Calling
  453.  
  454. Function Entry and Exit
  455. -----------------------
  456.  
  457.    This section describes the macros that output function entry
  458. ("prologue") and exit ("epilogue") code.
  459.  
  460. `FUNCTION_PROLOGUE (FILE, SIZE)'
  461.      A C compound statement that outputs the assembler code for entry
  462.      to a function.  The prologue is responsible for setting up the
  463.      stack frame, initializing the frame pointer register, saving
  464.      registers that must be saved, and allocating SIZE additional bytes
  465.      of storage for the local variables.  SIZE is an integer.  FILE is
  466.      a stdio stream to which the assembler code should be output.
  467.  
  468.      The label for the beginning of the function need not be output by
  469.      this macro.  That has already been done when the macro is run.
  470.  
  471.      To determine which registers to save, the macro can refer to the
  472.      array `regs_ever_live': element R is nonzero if hard register R is
  473.      used anywhere within the function.  This implies the function
  474.      prologue should save register R, provided it is not one of the
  475.      call-used registers.  (`FUNCTION_EPILOGUE' must likewise use
  476.      `regs_ever_live'.)
  477.  
  478.      On machines that have "register windows", the function entry code
  479.      does not save on the stack the registers that are in the windows,
  480.      even if they are supposed to be preserved by function calls;
  481.      instead it takes appropriate steps to "push" the register stack,
  482.      if any non-call-used registers are used in the function.
  483.  
  484.      On machines where functions may or may not have frame-pointers, the
  485.      function entry code must vary accordingly; it must set up the frame
  486.      pointer if one is wanted, and not otherwise.  To determine whether
  487.      a frame pointer is in wanted, the macro can refer to the variable
  488.      `frame_pointer_needed'.  The variable's value will be 1 at run
  489.      time in a function that needs a frame pointer.  *Note
  490.      Elimination::.
  491.  
  492.      The function entry code is responsible for allocating any stack
  493.      space required for the function.  This stack space consists of the
  494.      regions listed below.  In most cases, these regions are allocated
  495.      in the order listed, with the last listed region closest to the
  496.      top of the stack (the lowest address if `STACK_GROWS_DOWNWARD' is
  497.      defined, and the highest address if it is not defined).  You can
  498.      use a different order for a machine if doing so is more convenient
  499.      or required for compatibility reasons.  Except in cases where
  500.      required by standard or by a debugger, there is no reason why the
  501.      stack layout used by GCC need agree with that used by other
  502.      compilers for a machine.
  503.  
  504.         * A region of `current_function_pretend_args_size' bytes of
  505.           uninitialized space just underneath the first argument
  506.           arriving on the stack.  (This may not be at the very start of
  507.           the allocated stack region if the calling sequence has pushed
  508.           anything else since pushing the stack arguments.  But
  509.           usually, on such machines, nothing else has been pushed yet,
  510.           because the function prologue itself does all the pushing.)
  511.           This region is used on machines where an argument may be
  512.           passed partly in registers and partly in memory, and, in some
  513.           cases to support the features in `varargs.h' and `stdargs.h'.
  514.  
  515.         * An area of memory used to save certain registers used by the
  516.           function.  The size of this area, which may also include
  517.           space for such things as the return address and pointers to
  518.           previous stack frames, is machine-specific and usually
  519.           depends on which registers have been used in the function.
  520.           Machines with register windows often do not require a save
  521.           area.
  522.  
  523.         * A region of at least SIZE bytes, possibly rounded up to an
  524.           allocation boundary, to contain the local variables of the
  525.           function.  On some machines, this region and the save area
  526.           may occur in the opposite order, with the save area closer to
  527.           the top of the stack.
  528.  
  529.         * Optionally, when `ACCUMULATE_OUTGOING_ARGS' is defined, a
  530.           region of `current_function_outgoing_args_size' bytes to be
  531.           used for outgoing argument lists of the function.  *Note
  532.           Stack Arguments::.
  533.  
  534.      Normally, it is necessary for the macros `FUNCTION_PROLOGUE' and
  535.      `FUNCTION_EPILOGUE' to treat leaf functions specially.  The C
  536.      variable `current_function_is_leaf' is nonzero for such a function.
  537.  
  538. `EXIT_IGNORE_STACK'
  539.      Define this macro as a C expression that is nonzero if the return
  540.      instruction or the function epilogue ignores the value of the stack
  541.      pointer; in other words, if it is safe to delete an instruction to
  542.      adjust the stack pointer before a return from the function.
  543.  
  544.      Note that this macro's value is relevant only for functions for
  545.      which frame pointers are maintained.  It is never safe to delete a
  546.      final stack adjustment in a function that has no frame pointer,
  547.      and the compiler knows this regardless of `EXIT_IGNORE_STACK'.
  548.  
  549. `EPILOGUE_USES (REGNO)'
  550.      Define this macro as a C expression that is nonzero for registers
  551.      are used by the epilogue or the `return' pattern.  The stack and
  552.      frame pointer registers are already be assumed to be used as
  553.      needed.
  554.  
  555. `FUNCTION_EPILOGUE (FILE, SIZE)'
  556.      A C compound statement that outputs the assembler code for exit
  557.      from a function.  The epilogue is responsible for restoring the
  558.      saved registers and stack pointer to their values when the
  559.      function was called, and returning control to the caller.  This
  560.      macro takes the same arguments as the macro `FUNCTION_PROLOGUE',
  561.      and the registers to restore are determined from `regs_ever_live'
  562.      and `CALL_USED_REGISTERS' in the same way.
  563.  
  564.      On some machines, there is a single instruction that does all the
  565.      work of returning from the function.  On these machines, give that
  566.      instruction the name `return' and do not define the macro
  567.      `FUNCTION_EPILOGUE' at all.
  568.  
  569.      Do not define a pattern named `return' if you want the
  570.      `FUNCTION_EPILOGUE' to be used.  If you want the target switches
  571.      to control whether return instructions or epilogues are used,
  572.      define a `return' pattern with a validity condition that tests the
  573.      target switches appropriately.  If the `return' pattern's validity
  574.      condition is false, epilogues will be used.
  575.  
  576.      On machines where functions may or may not have frame-pointers, the
  577.      function exit code must vary accordingly.  Sometimes the code for
  578.      these two cases is completely different.  To determine whether a
  579.      frame pointer is wanted, the macro can refer to the variable
  580.      `frame_pointer_needed'.  The variable's value will be 1 when
  581.      compiling a function that needs a frame pointer.
  582.  
  583.      Normally, `FUNCTION_PROLOGUE' and `FUNCTION_EPILOGUE' must treat
  584.      leaf functions specially.  The C variable
  585.      `current_function_is_leaf' is nonzero for such a function.  *Note
  586.      Leaf Functions::.
  587.  
  588.      On some machines, some functions pop their arguments on exit while
  589.      others leave that for the caller to do.  For example, the 68020
  590.      when given `-mrtd' pops arguments in functions that take a fixed
  591.      number of arguments.
  592.  
  593.      Your definition of the macro `RETURN_POPS_ARGS' decides which
  594.      functions pop their own arguments.  `FUNCTION_EPILOGUE' needs to
  595.      know what was decided.  The variable that is called
  596.      `current_function_pops_args' is the number of bytes of its
  597.      arguments that a function should pop.  *Note Scalar Return::.
  598.  
  599. `DELAY_SLOTS_FOR_EPILOGUE'
  600.      Define this macro if the function epilogue contains delay slots to
  601.      which instructions from the rest of the function can be "moved".
  602.      The definition should be a C expression whose value is an integer
  603.      representing the number of delay slots there.
  604.  
  605. `ELIGIBLE_FOR_EPILOGUE_DELAY (INSN, N)'
  606.      A C expression that returns 1 if INSN can be placed in delay slot
  607.      number N of the epilogue.
  608.  
  609.      The argument N is an integer which identifies the delay slot now
  610.      being considered (since different slots may have different rules of
  611.      eligibility).  It is never negative and is always less than the
  612.      number of epilogue delay slots (what `DELAY_SLOTS_FOR_EPILOGUE'
  613.      returns).  If you reject a particular insn for a given delay slot,
  614.      in principle, it may be reconsidered for a subsequent delay slot.
  615.      Also, other insns may (at least in principle) be considered for
  616.      the so far unfilled delay slot.
  617.  
  618.      The insns accepted to fill the epilogue delay slots are put in an
  619.      RTL list made with `insn_list' objects, stored in the variable
  620.      `current_function_epilogue_delay_list'.  The insn for the first
  621.      delay slot comes first in the list.  Your definition of the macro
  622.      `FUNCTION_EPILOGUE' should fill the delay slots by outputting the
  623.      insns in this list, usually by calling `final_scan_insn'.
  624.  
  625.      You need not define this macro if you did not define
  626.      `DELAY_SLOTS_FOR_EPILOGUE'.
  627.  
  628. `ASM_OUTPUT_MI_THUNK (FILE, THUNK_FNDECL, DELTA, FUNCTION)'
  629.      A C compound statement that outputs the assembler code for a thunk
  630.      function, used to implement C++ virtual function calls with
  631.      multiple inheritance.  The thunk acts as a wrapper around a
  632.      virtual function, adjusting the implicit object parameter before
  633.      handing control off to the real function.
  634.  
  635.      First, emit code to add the integer DELTA to the location that
  636.      contains the incoming first argument.  Assume that this argument
  637.      contains a pointer, and is the one used to pass the `this' pointer
  638.      in C++.  This is the incoming argument *before* the function
  639.      prologue, e.g. `%o0' on a sparc.  The addition must preserve the
  640.      values of all other incoming arguments.
  641.  
  642.      After the addition, emit code to jump to FUNCTION, which is a
  643.      `FUNCTION_DECL'.  This is a direct pure jump, not a call, and does
  644.      not touch the return address.  Hence returning from FUNCTION will
  645.      return to whoever called the current `thunk'.
  646.  
  647.      The effect must be as if FUNCTION had been called directly with
  648.      the adjusted first argument.  This macro is responsible for
  649.      emitting all of the code for a thunk function; `FUNCTION_PROLOGUE'
  650.      and `FUNCTION_EPILOGUE' are not invoked.
  651.  
  652.      The THUNK_FNDECL is redundant.  (DELTA and FUNCTION have already
  653.      been extracted from it.)  It might possibly be useful on some
  654.      targets, but probably not.
  655.  
  656.      If you do not define this macro, the target-independent code in
  657.      the C++ frontend will generate a less efficient heavyweight thunk
  658.      that calls FUNCTION instead of jumping to it.  The generic
  659.      approach does not support varargs.
  660.  
  661. 
  662. File: gcc.info,  Node: Profiling,  Prev: Function Entry,  Up: Stack and Calling
  663.  
  664. Generating Code for Profiling
  665. -----------------------------
  666.  
  667.    These macros will help you generate code for profiling.
  668.  
  669. `FUNCTION_PROFILER (FILE, LABELNO)'
  670.      A C statement or compound statement to output to FILE some
  671.      assembler code to call the profiling subroutine `mcount'.  Before
  672.      calling, the assembler code must load the address of a counter
  673.      variable into a register where `mcount' expects to find the
  674.      address.  The name of this variable is `LP' followed by the number
  675.      LABELNO, so you would generate the name using `LP%d' in a
  676.      `fprintf'.
  677.  
  678.      The details of how the address should be passed to `mcount' are
  679.      determined by your operating system environment, not by GNU CC.  To
  680.      figure them out, compile a small program for profiling using the
  681.      system's installed C compiler and look at the assembler code that
  682.      results.
  683.  
  684. `PROFILE_BEFORE_PROLOGUE'
  685.      Define this macro if the code for function profiling should come
  686.      before the function prologue.  Normally, the profiling code comes
  687.      after.
  688.  
  689. `FUNCTION_BLOCK_PROFILER (FILE, LABELNO)'
  690.      A C statement or compound statement to output to FILE some
  691.      assembler code to initialize basic-block profiling for the current
  692.      object module.  The global compile flag `profile_block_flag'
  693.      distinguishes two profile modes.
  694.  
  695.     `profile_block_flag != 2'
  696.           Output code to call the subroutine `__bb_init_func' once per
  697.           object module, passing it as its sole argument the address of
  698.           a block allocated in the object module.
  699.  
  700.           The name of the block is a local symbol made with this
  701.           statement:
  702.  
  703.                ASM_GENERATE_INTERNAL_LABEL (BUFFER, "LPBX", 0);
  704.  
  705.           Of course, since you are writing the definition of
  706.           `ASM_GENERATE_INTERNAL_LABEL' as well as that of this macro,
  707.           you can take a short cut in the definition of this macro and
  708.           use the name that you know will result.
  709.  
  710.           The first word of this block is a flag which will be nonzero
  711.           if the object module has already been initialized.  So test
  712.           this word first, and do not call `__bb_init_func' if the flag
  713.           is nonzero.  BLOCK_OR_LABEL contains a unique number which
  714.           may be used to generate a label as a branch destination when
  715.           `__bb_init_func' will not be called.
  716.  
  717.           Described in assembler language, the code to be output looks
  718.           like:
  719.  
  720.                  cmp (LPBX0),0
  721.                  bne local_label
  722.                  parameter1 <- LPBX0
  723.                  call __bb_init_func
  724.                local_label:
  725.  
  726.     `profile_block_flag == 2'
  727.           Output code to call the subroutine `__bb_init_trace_func' and
  728.           pass two parameters to it.  The first parameter is the same as
  729.           for `__bb_init_func'.  The second parameter is the number of
  730.           the first basic block of the function as given by
  731.           BLOCK_OR_LABEL.  Note that `__bb_init_trace_func' has to be
  732.           called, even if the object module has been initialized
  733.           already.
  734.  
  735.           Described in assembler language, the code to be output looks
  736.           like:
  737.                parameter1 <- LPBX0
  738.                parameter2 <- BLOCK_OR_LABEL
  739.                call __bb_init_trace_func
  740.  
  741. `BLOCK_PROFILER (FILE, BLOCKNO)'
  742.      A C statement or compound statement to output to FILE some
  743.      assembler code to increment the count associated with the basic
  744.      block number BLOCKNO.  The global compile flag
  745.      `profile_block_flag' distinguishes two profile modes.
  746.  
  747.     `profile_block_flag != 2'
  748.           Output code to increment the counter directly.  Basic blocks
  749.           are numbered separately from zero within each compilation.
  750.           The count associated with block number BLOCKNO is at index
  751.           BLOCKNO in a vector of words; the name of this array is a
  752.           local symbol made with this statement:
  753.  
  754.                ASM_GENERATE_INTERNAL_LABEL (BUFFER, "LPBX", 2);
  755.  
  756.           Of course, since you are writing the definition of
  757.           `ASM_GENERATE_INTERNAL_LABEL' as well as that of this macro,
  758.           you can take a short cut in the definition of this macro and
  759.           use the name that you know will result.
  760.  
  761.           Described in assembler language, the code to be output looks
  762.           like:
  763.  
  764.                inc (LPBX2+4*BLOCKNO)
  765.  
  766.     `profile_block_flag == 2'
  767.           Output code to initialize the global structure `__bb' and
  768.           call the function `__bb_trace_func', which will increment the
  769.           counter.
  770.  
  771.           `__bb' consists of two words.  In the first word, the current
  772.           basic block number, as given by BLOCKNO, has to be stored.  In
  773.           the second word, the address of a block allocated in the
  774.           object module has to be stored.  The address is given by the
  775.           label created with this statement:
  776.  
  777.                ASM_GENERATE_INTERNAL_LABEL (BUFFER, "LPBX", 0);
  778.  
  779.           Described in assembler language, the code to be output looks
  780.           like:
  781.                move BLOCKNO -> (__bb)
  782.                move LPBX0 -> (__bb+4)
  783.                call __bb_trace_func
  784.  
  785. `FUNCTION_BLOCK_PROFILER_EXIT (FILE)'
  786.      A C statement or compound statement to output to FILE assembler
  787.      code to call function `__bb_trace_ret'.  The assembler code should
  788.      only be output if the global compile flag `profile_block_flag' ==
  789.      2.  This macro has to be used at every place where code for
  790.      returning from a function is generated (e.g. `FUNCTION_EPILOGUE').
  791.      Although you have to write the definition of `FUNCTION_EPILOGUE'
  792.      as well, you have to define this macro to tell the compiler, that
  793.      the proper call to `__bb_trace_ret' is produced.
  794.  
  795. `MACHINE_STATE_SAVE (ID)'
  796.      A C statement or compound statement to save all registers, which
  797.      may be clobbered by a function call, including condition codes.
  798.      The `asm' statement will be mostly likely needed to handle this
  799.      task.  Local labels in the assembler code can be concatenated with
  800.      the string ID, to obtain a unique lable name.
  801.  
  802.      Registers or condition codes clobbered by `FUNCTION_PROLOGUE' or
  803.      `FUNCTION_EPILOGUE' must be saved in the macros
  804.      `FUNCTION_BLOCK_PROFILER', `FUNCTION_BLOCK_PROFILER_EXIT' and
  805.      `BLOCK_PROFILER' prior calling `__bb_init_trace_func',
  806.      `__bb_trace_ret' and `__bb_trace_func' respectively.
  807.  
  808. `MACHINE_STATE_RESTORE (ID)'
  809.      A C statement or compound statement to restore all registers,
  810.      including condition codes, saved by `MACHINE_STATE_SAVE'.
  811.  
  812.      Registers or condition codes clobbered by `FUNCTION_PROLOGUE' or
  813.      `FUNCTION_EPILOGUE' must be restored in the macros
  814.      `FUNCTION_BLOCK_PROFILER', `FUNCTION_BLOCK_PROFILER_EXIT' and
  815.      `BLOCK_PROFILER' after calling `__bb_init_trace_func',
  816.      `__bb_trace_ret' and `__bb_trace_func' respectively.
  817.  
  818. `BLOCK_PROFILER_CODE'
  819.      A C function or functions which are needed in the library to
  820.      support block profiling.
  821.  
  822. 
  823. File: gcc.info,  Node: Varargs,  Next: Trampolines,  Prev: Stack and Calling,  Up: Target Macros
  824.  
  825. Implementing the Varargs Macros
  826. ===============================
  827.  
  828.    GNU CC comes with an implementation of `varargs.h' and `stdarg.h'
  829. that work without change on machines that pass arguments on the stack.
  830. Other machines require their own implementations of varargs, and the
  831. two machine independent header files must have conditionals to include
  832. it.
  833.  
  834.    ANSI `stdarg.h' differs from traditional `varargs.h' mainly in the
  835. calling convention for `va_start'.  The traditional implementation
  836. takes just one argument, which is the variable in which to store the
  837. argument pointer.  The ANSI implementation of `va_start' takes an
  838. additional second argument.  The user is supposed to write the last
  839. named argument of the function here.
  840.  
  841.    However, `va_start' should not use this argument.  The way to find
  842. the end of the named arguments is with the built-in functions described
  843. below.
  844.  
  845. `__builtin_saveregs ()'
  846.      Use this built-in function to save the argument registers in
  847.      memory so that the varargs mechanism can access them.  Both ANSI
  848.      and traditional versions of `va_start' must use
  849.      `__builtin_saveregs', unless you use `SETUP_INCOMING_VARARGS' (see
  850.      below) instead.
  851.  
  852.      On some machines, `__builtin_saveregs' is open-coded under the
  853.      control of the macro `EXPAND_BUILTIN_SAVEREGS'.  On other machines,
  854.      it calls a routine written in assembler language, found in
  855.      `libgcc2.c'.
  856.  
  857.      Code generated for the call to `__builtin_saveregs' appears at the
  858.      beginning of the function, as opposed to where the call to
  859.      `__builtin_saveregs' is written, regardless of what the code is.
  860.      This is because the registers must be saved before the function
  861.      starts to use them for its own purposes.
  862.  
  863. `__builtin_args_info (CATEGORY)'
  864.      Use this built-in function to find the first anonymous arguments in
  865.      registers.
  866.  
  867.      In general, a machine may have several categories of registers
  868.      used for arguments, each for a particular category of data types.
  869.      (For example, on some machines, floating-point registers are used
  870.      for floating-point arguments while other arguments are passed in
  871.      the general registers.)  To make non-varargs functions use the
  872.      proper calling convention, you have defined the `CUMULATIVE_ARGS'
  873.      data type to record how many registers in each category have been
  874.      used so far
  875.  
  876.      `__builtin_args_info' accesses the same data structure of type
  877.      `CUMULATIVE_ARGS' after the ordinary argument layout is finished
  878.      with it, with CATEGORY specifying which word to access.  Thus, the
  879.      value indicates the first unused register in a given category.
  880.  
  881.      Normally, you would use `__builtin_args_info' in the implementation
  882.      of `va_start', accessing each category just once and storing the
  883.      value in the `va_list' object.  This is because `va_list' will
  884.      have to update the values, and there is no way to alter the values
  885.      accessed by `__builtin_args_info'.
  886.  
  887. `__builtin_next_arg (LASTARG)'
  888.      This is the equivalent of `__builtin_args_info', for stack
  889.      arguments.  It returns the address of the first anonymous stack
  890.      argument, as type `void *'. If `ARGS_GROW_DOWNWARD', it returns
  891.      the address of the location above the first anonymous stack
  892.      argument.  Use it in `va_start' to initialize the pointer for
  893.      fetching arguments from the stack.  Also use it in `va_start' to
  894.      verify that the second parameter LASTARG is the last named argument
  895.      of the current function.
  896.  
  897. `__builtin_classify_type (OBJECT)'
  898.      Since each machine has its own conventions for which data types are
  899.      passed in which kind of register, your implementation of `va_arg'
  900.      has to embody these conventions.  The easiest way to categorize the
  901.      specified data type is to use `__builtin_classify_type' together
  902.      with `sizeof' and `__alignof__'.
  903.  
  904.      `__builtin_classify_type' ignores the value of OBJECT, considering
  905.      only its data type.  It returns an integer describing what kind of
  906.      type that is--integer, floating, pointer, structure, and so on.
  907.  
  908.      The file `typeclass.h' defines an enumeration that you can use to
  909.      interpret the values of `__builtin_classify_type'.
  910.  
  911.    These machine description macros help implement varargs:
  912.  
  913. `EXPAND_BUILTIN_SAVEREGS (ARGS)'
  914.      If defined, is a C expression that produces the machine-specific
  915.      code for a call to `__builtin_saveregs'.  This code will be moved
  916.      to the very beginning of the function, before any parameter access
  917.      are made.  The return value of this function should be an RTX that
  918.      contains the value to use as the return of `__builtin_saveregs'.
  919.  
  920.      The argument ARGS is a `tree_list' containing the arguments that
  921.      were passed to `__builtin_saveregs'.
  922.  
  923.      If this macro is not defined, the compiler will output an ordinary
  924.      call to the library function `__builtin_saveregs'.
  925.  
  926. `SETUP_INCOMING_VARARGS (ARGS_SO_FAR, MODE, TYPE, PRETEND_ARGS_SIZE, SECOND_TIME)'
  927.      This macro offers an alternative to using `__builtin_saveregs' and
  928.      defining the macro `EXPAND_BUILTIN_SAVEREGS'.  Use it to store the
  929.      anonymous register arguments into the stack so that all the
  930.      arguments appear to have been passed consecutively on the stack.
  931.      Once this is done, you can use the standard implementation of
  932.      varargs that works for machines that pass all their arguments on
  933.      the stack.
  934.  
  935.      The argument ARGS_SO_FAR is the `CUMULATIVE_ARGS' data structure,
  936.      containing the values that obtain after processing of the named
  937.      arguments.  The arguments MODE and TYPE describe the last named
  938.      argument--its machine mode and its data type as a tree node.
  939.  
  940.      The macro implementation should do two things: first, push onto the
  941.      stack all the argument registers *not* used for the named
  942.      arguments, and second, store the size of the data thus pushed into
  943.      the `int'-valued variable whose name is supplied as the argument
  944.      PRETEND_ARGS_SIZE.  The value that you store here will serve as
  945.      additional offset for setting up the stack frame.
  946.  
  947.      Because you must generate code to push the anonymous arguments at
  948.      compile time without knowing their data types,
  949.      `SETUP_INCOMING_VARARGS' is only useful on machines that have just
  950.      a single category of argument register and use it uniformly for
  951.      all data types.
  952.  
  953.      If the argument SECOND_TIME is nonzero, it means that the
  954.      arguments of the function are being analyzed for the second time.
  955.      This happens for an inline function, which is not actually
  956.      compiled until the end of the source file.  The macro
  957.      `SETUP_INCOMING_VARARGS' should not generate any instructions in
  958.      this case.
  959.  
  960. `STRICT_ARGUMENT_NAMING'
  961.      Define this macro to be a nonzero value if the location where a
  962.      function argument is passed depends on whether or not it is a
  963.      named argument.
  964.  
  965.      This macro controls how the NAMED argument to `FUNCTION_ARG' is
  966.      set for varargs and stdarg functions.  If this macro returns a
  967.      nonzero value, the NAMED argument is always true for named
  968.      arguments, and false for unnamed arguments.  If it returns a value
  969.      of zero, but `SETUP_INCOMING_VARARGS' is defined, then all
  970.      arguments are treated as named.  Otherwise, all named arguments
  971.      except the last are treated as named.
  972.  
  973.      You need not define this macro if it always returns zero.
  974.  
  975. `PRETEND_OUTGOING_VARARGS_NAMED'
  976.      If you need to conditionally change ABIs so that one works with
  977.      `SETUP_INCOMING_VARARGS', but the other works like neither
  978.      `SETUP_INCOMING_VARARGS' nor `STRICT_ARGUMENT_NAMING' was defined,
  979.      then define this macro to return nonzero if
  980.      `SETUP_INCOMING_VARARGS' is used, zero otherwise.  Otherwise, you
  981.      should not define this macro.
  982.  
  983.